package com.huanxun.fragment;

import com.huanxun.foodspath3.MessageActivity;
import com.huanxun.foodspath3.R;
import com.huanxun.utils.NetConnectiveUils;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Toast;
/**
 * 联网失败Fragment
 * 
 */
public class NetConnectiveFailedFragment extends Fragment{
	Context context;
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View v =inflater.inflate(R.layout.fragment_net_failed, null);
		v.findViewById(R.id.bt_reconnection).setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				MessageActivity activity =(MessageActivity)getActivity();
				if(NetConnectiveUils.isNetworkAvailable((Activity) context)){
					activity.getSupportFragmentManager().beginTransaction().replace(R.id.fl_msg,new MsgListFragment()).commit();
				}else{
					Toast.makeText(activity, "网络错误", Toast.LENGTH_SHORT).show();
				}
			}
		});
		
		return v;
	}
	
	@Override
	public void onAttach(Activity activity) {
		this.context=activity;
		super.onAttach(activity);
	}
}
